package com.mobile.persistent.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.mobile.persistent.base.BaseEntity;

/**
 * @author qingqiu
 * 职员表
 */
@Entity
@Table(name="staffs")
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
public class Staffs extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private String userName;
	private String password;
	/**
	 * 从职公司或分店
	 */
	private CompanyInfo companyInfo;
	/**
	 * 用户权限
	 */
	private List<UserPurview> userPurviews;
	/**
	 * 职位(超级管理员，店长，普通员工)
	 */
	private int office;

	@Column(name="userName", columnDefinition="varchar(10)", nullable=false)
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	@Column(name="password", columnDefinition="varchar(20)", nullable=false)
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="compId", columnDefinition="bigint")
	public CompanyInfo getCompanyInfo() {
		return companyInfo;
	}
	public void setCompanyInfo(CompanyInfo companyInfo) {
		this.companyInfo = companyInfo;
	}
	@Column(name="office", columnDefinition="bit")
	public int getOffice() {
		return office;
	}
	public void setOffice(int office) {
		this.office = office;
	}
	@OneToMany(mappedBy="user", fetch=FetchType.LAZY)
	@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
		org.hibernate.annotations.CascadeType.DELETE,
		org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
	public List<UserPurview> getUserPurviews() {
		return userPurviews;
	}
	public void setUserPurviews(List<UserPurview> userPurviews) {
		this.userPurviews = userPurviews;
	}
	
}
